Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce the memory footprint of an automatic reset #6567

Merged
merged 3 commits into from
May 4, 2023

Conversation

ironage
Copy link
Contributor

@ironage ironage commented May 4, 2023

The sync history can be short circuited because it will be discarded right after transfer_group()

I made a temporary client reset test that inserted a bunch of large strings on the server state so that transfer_group had to insert them and recorded the memory use before and after using /usr/bin/time -l ./test/object-store/realm-object-store-tests.app/Contents/MacOS/realm-object-store-tests "sync: client reset" -c "recovery" -c "insert" -d yes
The amount of memory difference will vary widely based on the actual data, but I take the following improvement from my synthetic test to be an indication of improvement:
Before: 17581760 peak memory footprint
After: 13338304 peak memory footprint

The sync history can be short circuited because it
will be discarded right after `transfer_group()`
@ironage ironage requested review from tgoyne, jedelbo and michael-wb May 4, 2023 00:25
@ironage ironage self-assigned this May 4, 2023
@cla-bot cla-bot bot added the cla: yes label May 4, 2023
// away immediately after anyways. This reduces the memory footprint of a client reset.
ClientReplication* client_repl = dynamic_cast<ClientReplication*>(group_dst.get_replication());
REALM_ASSERT_RELEASE(client_repl);
client_repl->set_short_circuit(true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TempShortCircuitReplication is a helper to do this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just what I needed, thanks! Updated.

@michael-wb
Copy link
Contributor

Looks good - thanks for looking into this! We'll see about creating another build tomorrow to see if this helps the customer.

@danieltabacaru danieltabacaru self-requested a review May 4, 2023 06:44
@ironage
Copy link
Contributor Author

ironage commented May 4, 2023

Incidentally, this also improves performance in cases where the difference of the fresh Realm to the local Realm requires many changes. Running the object-store client reset benchmarks showed improvements in the following scenarios:

client reset
  Recover: 5000 source objects linked to 5000 dest objects
  remote removes half the local data
  mean: 29ms before 26.8ms after = 8% improvement

  client reset
  DiscardLocal: 5000 source objects linked to 5000 dest objects
  local removes half the objects
  mean: 43ms before, 34ms after = 26% improvement

  client reset
  DiscardLocal: populated with 10000 simple objects
  local removes half the objects
  mean: 29ms before, 23.7ms after = 22% improvement

@ironage ironage merged commit a6cd096 into master May 4, 2023
@ironage ironage deleted the js/reset-without-sync-hist branch May 4, 2023 17:06
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants